package com.refusea.train.controller

import com.refusea.train.domain.entity.Order
import com.refusea.train.domain.helper.OrderHelper
import com.refusea.train.domain.req.OrderReq
import com.refusea.train.domain.vo.PaginationVo
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author Zhang Yan 2024/4/4
 **/
@RestController
@RequestMapping("/api/private/order/")
class OrderController(private val orderHelper: OrderHelper) {

    @PostMapping("/list")
    fun list(@RequestBody req: OrderReq): PaginationVo {
        return orderHelper.query(req)
    }

    @PostMapping("/save")
    fun create(@RequestBody order: Order): Int {
        return orderHelper.save(order)
    }

    @GetMapping("/paid")
    fun paid(id: Int) {
        orderHelper.markPaid(id)
    }
}
